package com.masterclient.app.modules.firstpager.fragments.adapters;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.App;
import com.masterclient.app.R;
import com.eoner.baselibrary.bean.firstpager.VideoListBean;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.masterclient.app.widget.CircleBorderTransform;

import butterknife.BindView;

/**
 * 作者：sean
 * 创建时间：2017/6/20 11:26
 * 功能说明：视频列表适配器
 */

public class VideoRecyclerAdapter extends BaseQuickAdapter<VideoListBean.DataBean.ShVideosBean, BaseViewHolder> {
    @BindView(R.id.iv_brand_logo)
    ImageView ivBrandLogo;
    @BindView(R.id.tv_brand_name)
    TextView tvBrandName;
    @BindView(R.id.tv_vote_num)
    TextView tvVoteNum;
    @BindView(R.id.iv_video)
    ImageView ivVideo;
    @BindView(R.id.iv_bofang)
    ImageView ivBofang;
    @BindView(R.id.tv_video_name)
    TextView tvVideoName;
    @BindView(R.id.tv_play_num)
    TextView tvPlayNum;
    @BindView(R.id.tv_video_long)
    TextView tvVideoLong;
    @BindView(R.id.iv_vote)
    ImageView ivVote;

    private String vote_num_image,enter_vote_image;

    private String sh_is_show_vote;

    public VideoRecyclerAdapter() {
        super(R.layout.view_item_video);
    }

    public void setImage(String vote_num_image,String enter_vote_image){
        this.vote_num_image = vote_num_image;
        this.enter_vote_image = enter_vote_image;
    }

    @Override
    protected void convert(BaseViewHolder helper, VideoListBean.DataBean.ShVideosBean item) {

        if(!TextUtils.isEmpty(item.getSh_image())){
            App.picasso.load(item.getSh_image()).resize(ScreenUtils.getScreenWidth(),ScreenUtils.dp2px(187)).into((ImageView) helper.getView(R.id.iv_video));
        }
        if(!TextUtils.isEmpty(item.getSh_brand_logo())){
            App.picasso.load(item.getSh_brand_logo()).transform(new CircleBorderTransform(1,R.color.transparent)).resize(ScreenUtils.dp2px(40),ScreenUtils.dp2px(40)).into((ImageView) helper.getView(R.id.iv_brand_logo));
        }
        if(!TextUtils.isEmpty(vote_num_image)){
            App.picasso.load(vote_num_image).fit().into((ImageView) helper.getView(R.id.iv_vote_num));
        }

        if(!TextUtils.isEmpty(enter_vote_image)){
            App.picasso.load(enter_vote_image).fit().into((ImageView) helper.getView(R.id.iv_vote));
        }
        if("1".equals(sh_is_show_vote)){
            helper.getView(R.id.tv_vote_num).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_vote_num).setVisibility(View.VISIBLE);
            helper.getView(R.id.iv_vote).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.tv_vote_num).setVisibility(View.GONE);
            helper.getView(R.id.iv_vote_num).setVisibility(View.GONE);
            helper.getView(R.id.iv_vote).setVisibility(View.GONE);
        }

        helper.setText(R.id.tv_brand_name,item.getSh_brand_name());
        helper.setText(R.id.tv_vote_num,item.getSh_vote_num());
        helper.setText(R.id.tv_video_name,item.getSh_name());
        helper.setText(R.id.tv_play_num,item.getSh_play_num());
        helper.setText(R.id.tv_video_long,item.getSh_time_length());
        helper.setText(R.id.tv_video_no,item.getSh_code()+"号");

    }

    public void setSh_is_show_vote(String sh_is_show_vote) {
        this.sh_is_show_vote = sh_is_show_vote;
    }
}
